package com.dao.front.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.dao.BaseDao;
import com.dao.front.IIndexFrontDao;
@Repository
public class IndexDaoFrontImpl extends BaseDao implements IIndexFrontDao {

	@Override
	public List<Map<String, Object>> doExecuteQuerySongs() {
		String sql="select musicId,musicName,m.timeLength,m.musicMp3,m.musicTypeId,m.specialId,m.musicListId,m.singerId,"
			       +" mt.musicTypeId,mt.musicTypeName,"
			       +" sp.specialId,sp.specialName,"
			       +" ml.musicListId,ml.musicListName,ml.musicListIntro,ml.musicListPhoto,"
			       +" s.singerId,s.singerName"
			       +" from music m"
			       +" join musictype mt"
			       +" on m.musicTypeId=mt.musicTypeId"
			       +" join special sp"
			       +" on m.specialId=sp.specialId"
			       +" join musiclist ml"
			       +" on m.musicListId=ml.musicListId"
			       +" join singer s"
			       +" on m.singerId=s.singerId"
			       +" group by ml.musicListId"
			       +" order by ml.musicListId desc"
			       +" limit 0,5 ";
		return executeQuery(sql, null);
	}

	@Override
	public List<Map<String, Object>> doExecuteQuerySingers() {
		String sql="select  m.musicId,m.musicName,m.timeLength,m.musicMp3,m.musicPhoto,m.singerId,"
			     +"  si.singerId,si.singerName,si.seName,si.state,si.address,si.birthday,si.singerPhoto" 
				 +"  from music m "
				 + " join singer si "
				 + " on m.singerId=si.singerId"
				 + " order by m.musicId desc "
				 + " limit 0,9";
		
		return executeQuery(sql, null);
	}

	@Override
	public List<Map<String, Object>> doExecuteQueryxindie() {
		String sql="select s.specialId,s.specialName,s.specialType,s.language,s.issueDate,s.recordCompany,s.specialPhoto,s.specialIntro,"
                +"g.singerId,g.singerName,g.seName,g.state,g.address,g.work,g.birthday,g.singerPhoto,"
                +"m.musicId,m.musicName,m.timeLength,m.musicMp3 "
				+ " from special as s "
				+ " left join music as m  "
				+ " on m.specialId = s.specialId"
				+ "  left join singer as g   "
				+ " on m.singerId=g.singerId "
				+ " group by s.specialName"
				+ " order by s.specialId desc"
				+ " limit 0,10";
		return executeQuery(sql, null);
	}
	
	@Override
	public List<Map<String, Object>> doExecuteQueryMv() {
		String sql="select m.mvId,m.mvName,m.mvMp4,m.mvPhoto,m.mvTypeId,m.singerId,"
				+ " mv.mvTypeId,mv.mvTypeName,"
				+ " s.singerId,s.singerName"
				+ " from mv m"
				+ " join mvtype mv"
				+ " on m.mvTypeId=mv.mvTypeId"
				+ " join singer s"
				+ " on m.singerId=s.singerId"
				+ " order by m.mvId desc "
				+ " limit 0,10";
		return executeQuery(sql, null);
	}

}
